home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Textfiles / zines / Happle / happle10.sit.hqx / Happle#10 / Files / Denial.sit / DoS / pron.c < prev    next >
C/C++ Source or Header  |  1998-12-06  |  6KB  |  196 lines

  1. /* pr0n clicker 1.0 by HoGs HeaD
  2.  * -----------------------------
  3.  * Howdy. Whoah, it's been a while since I released a program! Well, su1d
  4.  * gave me the idea for this program and he is supposedly going to make a 
  5.  * Windows version soon.
  6.  * 
  7.  * What this program does: You know those banners that give you ten cents
  8.  * or something cheap when they're clicked? Well, this program will click 
  9.  * a banner with a list of wingates you have, so you can just have a large 
  10.  * list of wingates, turn this on, and start gaining some money.
  11.  * 
  12.  * This also has functions for downloading http files through wingates or just
  13.  * plain downloading the http file. You may use these functions provided they
  14.  * are in a different program than this, and that you don't sell the program
  15.  * you use that code for. When you download this code you agree to not claim
  16.  * this code as your own.
  17.  * 
  18.  * Special thanks to: SIN, duke(for being a massah debugger), su1d(for the
  19.  * idea)
  20.  * ------- hawgshead@yahoo.com ------------------------------------- */
  21.  
  22. #include <stdio.h>
  23. #include <string.h>
  24. #include <netdb.h>
  25. #include <sys/socket.h>
  26. #include <sys/types.h>
  27. #include <netinet/in.h>
  28. #include <netinet/ip.h>
  29.  
  30. /* Cute function to download an HTTP file, compliments of me. */
  31.  
  32. void downloadHttpFile(char *server, char *file)
  33. {
  34.    FILE *fp;
  35.    struct hostent *getFrom;
  36.    struct sockaddr_in from;
  37.    char inBuff[100], *oldBuff, outBuff[100];
  38.    int sckFd, isConnected, numSent;
  39.    
  40.    if(isdigit(*server)){
  41.       from.sin_addr.s_addr = inet_addr(server);
  42.    }else{
  43.       getFrom = gethostbyname(server);
  44.       strncpy((char *)&from.sin_addr, (char *)getFrom->h_addr, sizeof(from.sin_addr));
  45.    }
  46.    from.sin_family = AF_INET;
  47.    from.sin_port = htons(80);
  48.    sckFd = socket(AF_INET, SOCK_STREAM, 0);
  49.    
  50.    if(sckFd < 0){
  51.       printf("Socket could not be established.\n");
  52.       exit(0);
  53.    };
  54.    isConnected = connect(sckFd, (struct sockaddr *)&from, sizeof(from));
  55.    if(isConnected < 0){
  56.       printf("Connection failed.\n");
  57.       exit(0);      
  58.    }else{
  59.       printf("Connection success.\n");
  60.        
  61.    snprintf(outBuff, sizeof(outBuff), "GET %s\n", file);
  62.  
  63.    numSent=send(sckFd, outBuff, sizeof(outBuff), 0);
  64.    fflush(0);   
  65.    if((fp=fopen("temp.html", "w"))==NULL){
  66.       printf("Error opening temporary file for writing!\n");
  67.       exit(0);
  68.    }
  69.    
  70.       get:
  71.    numSent=recv(sckFd, inBuff, sizeof(inBuff), 0);
  72.    oldBuff=inBuff;
  73.    fprintf(fp, "%s", inBuff);
  74.    if((strstr(oldBuff, "</HTML>"))==NULL){
  75.      bzero(inBuff, sizeof(inBuff));
  76.      goto get;
  77.    }else{   
  78.       fclose(fp);
  79.    }
  80.          
  81.    printf("HTTP download complete.\n");   
  82.    };
  83.    close(sckFd);
  84. }
  85.  
  86. /* Download an HTTP file through a WinGate. Woop! */
  87.  
  88. void throughWingate(char *wserver, char *httpServer, char *wfile)
  89. {
  90.    FILE *wfp;
  91.    struct hostent *wgetFrom;
  92.    struct sockaddr_in wfrom;
  93.    char winBuff[100], *woldBuff, woutBuff[100];
  94.    int wsckFd, wisConnected, wnumSent;
  95.    
  96.    if(isdigit(*wserver)){
  97.       wfrom.sin_addr.s_addr = inet_addr(wserver);
  98.    }else{
  99.       wgetFrom = gethostbyname(wserver);
  100.       strncpy((char *)&wfrom.sin_addr, (char *)wgetFrom->h_addr, sizeof(wfrom.sin_addr));   
  101.    }
  102.    wfrom.sin_family = AF_INET;
  103.    wfrom.sin_port   = htons(23);
  104.    wsckFd = socket(AF_INET, SOCK_STREAM, 0);
  105.    
  106.    if(wsckFd < 0){
  107.       printf("Socket could not be established.\n");
  108.       exit(0);
  109.    };
  110.    wisConnected = connect(wsckFd, (struct sockaddr *)&wfrom, sizeof(wfrom));
  111.    if(wisConnected < 0){
  112.       printf("Connection could not be established.\n");
  113.    }else{
  114.       printf("Connection success.\n");
  115.       snprintf(woutBuff, sizeof(woutBuff), "%s 80\n", httpServer);
  116.       
  117.       do{
  118.       bzero(winBuff, sizeof(winBuff));
  119.       read(wsckFd, winBuff, sizeof(winBuff));
  120.       }while((strstr(winBuff, "WinGate>"))==NULL);
  121.       printf("Connection established, sending commands.\n");
  122.       write(wsckFd, woutBuff, strlen(woutBuff));
  123.       do{
  124.      bzero(winBuff, sizeof(winBuff));
  125.      read(wsckFd, winBuff, sizeof(winBuff));
  126.       }while((strstr(winBuff, "Connected"))==NULL);
  127.       printf("Connection established through WinGate->Server.\n");
  128.  
  129.       snprintf(woutBuff, sizeof(woutBuff), "GET %s\n", wfile);
  130.       write(wsckFd, woutBuff, strlen(woutBuff));
  131.       fflush(0);
  132.       if((wfp=fopen("temp.html", "w"))==NULL){
  133.      printf("Unable to open temporary file for output!\n");
  134.      exit(0);
  135.       }
  136.       getit:
  137.      read(wsckFd, winBuff, sizeof(winBuff));
  138.          woldBuff=winBuff;
  139.          fprintf(wfp, "%s", winBuff);
  140.       if((strstr(winBuff, "</HTML>"))==NULL){
  141.      bzero(winBuff, sizeof(winBuff));
  142.      goto getit;
  143.       }else{
  144.      fclose(wfp);
  145.       }
  146.       printf("HTTP download complete.\n");
  147.      
  148.    }
  149.    close(wsckFd);
  150. }
  151.  
  152. /* Parse the WinGate file and try each entry in the file. */
  153.  
  154. void parseGates(char *gateFile, char *httpServ, char *fileName)
  155. {
  156.    FILE *gate;
  157.    char currGate[100];
  158.  
  159.    int i=0;
  160.  
  161.    
  162.    if((gate=fopen(gateFile, "r"))==NULL){
  163.       printf("Error opening WinGate list.\n");
  164.       exit(0);
  165.    }
  166.    while(fgets(currGate, 80, gate) != NULL){
  167.    *(strchr(currGate, '\n')) = '\0';   
  168.    throughWingate(currGate, httpServ, fileName);
  169.    }
  170.    
  171.    fclose(gate);
  172. }
  173.  
  174. /* Main function. */
  175.  
  176. void main(int argc, char **argv){
  177.    printf("HoGs HeaD's Linux pr0n clicker 1.0.\nhawgshead@yahoo.com\n");
  178.    printf("-----------------------------------\n");
  179.    if(argc < 3){
  180.       printf("Usage: pron (server) (file) (wingate list)\n EX. pron www.yahoo.com /index.html wingate.list\n");
  181.       exit(0);
  182.    };
  183.    
  184.    printf("Connecting from localhost\n");
  185.    printf("-------------------------\n");
  186.    downloadHttpFile(argv[1], argv[2]);
  187.    printf("------------------------\n");
  188.    printf("Connecting from WinGates\n");
  189.    printf("------------------------\n");
  190.    parseGates(argv[3], argv[1], argv[2]);
  191.    unlink("temp.html");
  192. }
  193.  
  194.  
  195.  
  196.